package com.kehongborui.net;

/**
 * 手机号中间字段替换
 */
public class PhoneNumberValidDemo {
    public static void main(String[] args) {
        String password = "11a";

        System.out.println("15388881111".replaceFirst("[\\d]+", "AA"));
        System.out.println(replace("15388881111"));
    }

    /**
     * 1. 指定规则
     * 2. 根据规则替换
     * @return
     */
    public static String replace(String phoneNo) {
        String reg = "([\\d]{3})([\\d]{4})([\\d]{4})";   // 153 8888 1111 替换的是第一组到第三组之间的内容

        return phoneNo.replaceAll(reg, "$1********$3");
    }
}
